import axios from 'axios'
import {Modal} from 'antd';
import React from 'react';
import {
    ExclamationCircleOutlined,
} from '@ant-design/icons';

axios.defaults.withCredentials = true;
const { warning } = Modal;

// axios.interceptors.request.use(function (params) {
//     console.log('拦截器之前。。。。',params);
//     return params;
// },function (error) {
//     return Promise.reject(error);
// })

axios.interceptors.response.use(function (params) {
    let data = params.data;
    if(data.code == -10){
        Modal.destroyAll()
        warning({
            title: '退出提醒',
            icon: <ExclamationCircleOutlined />,
            content: '当前会话失效，您将退出系统,请重新登录',
            okText: '确定',
            okType: 'danger',
            onOk:()=> {
                window.location.href = './login'
            },
          });
    }
    return params;
},function (error) {
    // window.location.href = '/page500'
    return Promise.reject(error);
})

export default axios;